<template>
    <div class="sysWorkFlow">
        <div class="buttons">
            <el-button icon="el-icon-plus">部署流程定义</el-button>
            <el-button icon="el-icon-delete">删除</el-button>
            <el-input style="flex:1;margin-left:100px" placeholder="请输入流程定义名称" prefix-icon="el-icon-search" v-model="searchKey">
            </el-input>
        </div>
        <div class="sysWorkFlowTable">
            <el-skeleton style="width:100%;margin-top:15px;padding: 0px 10px" v-if="!isShowTable" :rows="15" animated />
            <el-table v-if="isShowTable" :data="tableData" style="width: 100%" ref="roleTable">
                <el-table-column type="selection" label="序号">
                </el-table-column>
                <el-table-column prop="id" label="流程定义ID">
                </el-table-column>
                <el-table-column prop="key" label="流程定义key">
                </el-table-column>
                <el-table-column prop="name" label="流程定义名称">
                </el-table-column>
                <el-table-column prop="deploymentId" label="流程部署ID">
                </el-table-column>
                <el-table-column prop="description" label="流程定义描述">
                </el-table-column>
            </el-table>
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :page-sizes="[10,50,100, 200, 300, 400]" :page-size="10" layout="total, sizes, prev, pager, next, jumper" :total="total">
            </el-pagination>
        </div>
    </div>
</template>
<script lang="ts">
    import { Component, Vue, Watch } from 'vue-property-decorator'
    import { Action, Getter } from 'vuex-class'
    import logo from '@/components/common/images/logo.png'
    import { namespace } from 'vuex-class';
    import * as _ from 'lodash';
    import AdminApiActions from "@/components/api/admin-api-actions";
    @Component({
        components: {}
    })
    export default class SysWorkFlow extends Vue {
        public isShowAddRole: boolean = false;
        public tableData: Array < any >= new Array < any > ();
        public params: any = {};
        public total: Number = 0;
        public isShowTable: boolean = false;
        public pageSize: number = 10;
        public curPage: Number = 1;
        public roleType: any = "";
        public isShowGrantDialog: boolean = false;
        public searchKey: any = "";
        async created() {
            this.roleType = this.$route.query.type;
            await this.initTableData();
        }

        public async initTableData() {
            let result: any = await AdminApiActions.getDefPage({ name: "", pager: { pageSize: this.pageSize, currentPage: this.curPage } });
            this.tableData = result.data.rows;
            this.total = result.data.total;
            this.isShowTable = true;
        }
        //每页数量改变
        public async handleSizeChange(pageSize: any) {
            this.isShowTable = false;
            this.pageSize = pageSize;
            await this.initTableData();
        }
        //页数改变
        public async handleCurrentChange(curPage: any) {
            this.isShowTable = false;
            this.curPage = curPage;
            await this.initTableData();
        }
    }
</script>
<style lang="less">
    .sysWorkFlow {
        width: 100%;
        background-color: white;
        height: 100%;

        .el-main {
            padding: 0px 20px;
        }

        .buttons {
            display: flex;
            flex-direction: row;
        }

        .sysWorkFlowTable {
            .el-table__body-wrapper {
                overflow-y: auto;
                height: calc(100% - 70px);
            }

            height: calc(100% - 60px);

            .el-table {
                height: calc(100% - 40px);
            }

            .el-pagination {
                margin-top: 12px;
            }
        }

        .el-dialog__body {
            padding: 5px 20px;
        }

        .el-dialog__footer {
            padding: 0px 20px 20px;
        }

        .el-form-item {
            display: flex;

            .el-form-item__label {
                width: 100px;
            }

            .el-form-item__content {
                flex: 1;
                margin-right: 40px;
            }
        }
    }
</style>